home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kcursor.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  6.6 KB  |  225 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 1998 Kurt Granroth (granroth@kde.org)
  3.                  2000 Carsten Pfeiffer <pfeiffer@kde.org>
  4.  
  5.    This library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License version 2 as published by the Free Software Foundation.
  8.  
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this library; see the file COPYING.LIB.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.    Boston, MA 02110-1301, USA.
  18. */
  19. /*
  20.  * $Id: kcursor.h 465272 2005-09-29 09:47:40Z mueller $
  21.  *
  22.  */
  23. #ifndef _KCURSOR_H
  24. #define _KCURSOR_H
  25.  
  26. #include <qcursor.h>
  27. #include <kdelibs_export.h>
  28.  
  29. class QWidget;
  30.  
  31. /**
  32.  * @short A QCursor wrapper allowing "themed" cursors and auto-hiding cursors.
  33.  *
  34.  * A wrapper around QCursor that allows for "themed" cursors.
  35.  *
  36.  * Currently, the only themed cursor is a hand shaped cursor.
  37.  *
  38.  * A typical usage would be
  39.  * \code
  40.  * setCursor(KCursor::handCursor());
  41.  * \endcode
  42.  *
  43.  * @author Kurt Granroth <granroth@kde.org>
  44.  */
  45. class KDEUI_EXPORT KCursor : public Qt
  46. {
  47. public:
  48.     /**
  49.      * Constructor.
  50.      *
  51.      * Does not do anything so far.
  52.      **/
  53.     KCursor();
  54.  
  55.     /**
  56.      * Returns the proper hand cursor according to
  57.      * the current GUI style (static function).
  58.      */
  59.     static QCursor handCursor();
  60.  
  61.     /**
  62.      * Returns the proper arrow+hourglass cursor according to
  63.      * the current GUI style (static function).
  64.      */
  65.     static QCursor workingCursor();
  66.  
  67.     /**
  68.      * Returns the proper arrow cursor according to
  69.      * the current GUI style (static function).
  70.      */
  71.     static QCursor arrowCursor();
  72.  
  73.     /**
  74.      * Returns the proper up arrow cursor according to
  75.      * the current GUI style (static function).
  76.      */
  77.     static QCursor upArrowCursor();
  78.  
  79.     /**
  80.      * Returns the proper cross-hair cursor according to
  81.      * the current GUI style (static function).
  82.      */
  83.     static QCursor crossCursor();
  84.  
  85.     /**
  86.      * Returns the proper hourglass cursor according to
  87.      * the current GUI style (static function).
  88.      */
  89.     static QCursor waitCursor();
  90.  
  91.     /**
  92.      * Returns the proper text cursor according to
  93.      * the current GUI style (static function).
  94.      */
  95.     static QCursor ibeamCursor();
  96.  
  97.     /**
  98.      * Returns the proper vertical resize cursor
  99.      * according to the current GUI style (static function).
  100.      */
  101.     static QCursor sizeVerCursor();
  102.  
  103.     /**
  104.      * Returns the proper horizontal resize cursor
  105.      * according to the current GUI style (static function).
  106.      */
  107.     static QCursor sizeHorCursor();
  108.  
  109.     /**
  110.      * Returns the proper diagonal resize (/) cursor
  111.      * according to the current GUI style (static function).
  112.      */
  113.     static QCursor sizeBDiagCursor();
  114.  
  115.     /**
  116.      * Returns the proper diagonal resize (\) cursor
  117.      * according to the current GUI style (static function).
  118.      */
  119.     static QCursor sizeFDiagCursor();
  120.  
  121.     /**
  122.      * Returns the proper all-directions resize cursor
  123.      * according to the current GUI style (static function).
  124.      */
  125.     static QCursor sizeAllCursor();
  126.  
  127.     /**
  128.      * Returns a blank or invisible cursor (static function).
  129.      */
  130.     static QCursor blankCursor();
  131.  
  132.     /**
  133.      * Returns a WhatsThis cursor (static function).
  134.      */
  135.     static QCursor whatsThisCursor();
  136.  
  137.     /**
  138.      * Sets auto-hiding the cursor for widget @p w. Enabling it will result in
  139.      * the cursor being hidden when
  140.      * @li a key-event happens
  141.      * @li there are no key-events for a configured time-frame (see
  142.      * setHideCursorDelay())
  143.      *
  144.      * The cursor will be shown again when the focus is lost or a mouse-event
  145.      * happens.
  146.      *
  147.      * Side effect: when enabling auto-hide, mouseTracking is enabled for the
  148.      * specified widget, because it's needed to get mouse-move-events. So
  149.      * don't disable mouseTracking for a widget while using auto-hide for it.
  150.      *
  151.      * When disabling auto-hide, mouseTracking will be disabled, so if you need
  152.      * mouseTracking after disabling auto-hide, you have to reenable
  153.      * mouseTracking.
  154.      *
  155.      * If you want to use auto-hiding for widgets that don't take focus, e.g.
  156.      * a QCanvasView, then you have to pass all key-events that should trigger
  157.      * auto-hiding to autoHideEventFilter().
  158.      */
  159.     static void setAutoHideCursor( QWidget *w, bool enable );
  160.  
  161.     /**
  162.      * Overloaded method for the case where you have an event-filter installed
  163.      * on the widget you want to enable auto-cursor-hiding.
  164.      *
  165.      * In this case set @p customEventFilter to true and call
  166.      * autoHideEventFilter() from the beginning of your eventFilter().
  167.      *
  168.      * @see autoHideEventFilter
  169.      */
  170.     static void setAutoHideCursor( QWidget *w, bool enable,
  171.                    bool customEventFilter );
  172.  
  173.     /**
  174.      * Sets the delay time in milliseconds for auto-hiding. When no keyboard
  175.      * events arrive for that time-frame, the cursor will be hidden.
  176.      *
  177.      * Default is 5000, i.e. 5 seconds.
  178.      */
  179.     static void setHideCursorDelay( int ms );
  180.  
  181.     /**
  182.      * @returns the current auto-hide delay time.
  183.      *
  184.      * Default is 5000, i.e. 5 seconds.
  185.      */
  186.     static int hideCursorDelay();
  187.  
  188.     /**
  189.      * KCursor has to install an eventFilter over the widget you want to
  190.      * auto-hide. If you have an own eventFilter() on that widget and stop
  191.      * some events by returning true, you might break auto-hiding, because
  192.      * KCursor doesn't get those events.
  193.      *
  194.      * In this case, you need to call setAutoHideCursor( widget, true, true );
  195.      * to tell KCursor not to install an eventFilter. Then you call this method
  196.      * from the beginning of your eventFilter, for example:
  197.      * \code
  198.      * edit = new KEdit( this, "some edit widget" );
  199.      * edit->installEventFilter( this );
  200.      * KCursor::setAutoHideCursor( edit, true, true );
  201.      *
  202.      * [...]
  203.      *
  204.      * bool YourClass::eventFilter( QObject *o, QEvent *e )
  205.      * {
  206.      *     if ( o == edit ) // only that widget where you enabled auto-hide!
  207.      *         KCursor::autoHideEventFilter( o, e );
  208.      *
  209.      *     // now you can do your own event-processing
  210.      *     [...]
  211.      * }
  212.      * \endcode
  213.      *
  214.      * Note that you must not call KCursor::autoHideEventFilter() when you
  215.      * didn't enable or after disabling auto-hiding.
  216.      */
  217.     static void autoHideEventFilter( QObject *, QEvent * );
  218.  
  219. private:
  220.     static QCursor *s_handCursor;
  221. };
  222.  
  223.  
  224. #endif // _KCURSOR_H
  225.